找传奇、传世资源到传世资源站!

海康摄像云台控制

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboardusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;using System.Windows.Forms;namespace yundemo{ public partial class Form1 : Form { public Form1() { InitializeComponent(); context = SynchronizationContext.Current; // 线程间信息同步 } #region 视频 SynchronizationContext context = SynchronizationContext.Current; // 线程间信息同步 bool isStartVideo1 = false; /// <summary> /// 登录ID /// </summary> private int pLoginID1 = -1; /// <summary> /// 硬件信息 /// </summary> // private CHCNetSDK.NET_DVR_DEVICEINFO_V30 deviceInfo; //获取视频路数 private int BindVideo1 = 0; private int[] pRealPlayHandle; public void InitVideo() { try { ThreadStart tsVideo = new ThreadStart(delegate () { context.Post((o) => { pRealPlayHandle = new int[4]; BindVideo1 = 0; #region 摄像头1 isStartVideo1 = CHCNetSDK.NET_DVR_Init(); //设置连接时间与重连时间 //设备用户信息获得 CHCNetSDK.NET_DVR_DEVICEINFO_V30 deviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V30(); pLoginID1 = CHCNetSDK.NET_DVR_Login_V30(IP, Port, Admin, Password, ref deviceInfo); if (pLoginID1 != -1) { // byte CountNum = this.deviceInfo.byChanNum >= deviceInfo.byIPChanNum ? deviceInfo.byChanNum : deviceInfo.byIPChanNum; CHCNetSDK.NET_DVR_PREVIEWINFO lpClientInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO(); lpClientInfo.lChannel = 1; BindVideo1 = 1; lpClientInfo.dwStreamType = 1;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推 lpClientInfo.dwLinkMode = 1;//连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTPlpClientInfo.bBlocked = false; //0- 非阻塞取流,1- 阻塞取流lpClientInfo.hPlayWnd = this.pictureBox1.Handle; IntPtr pUser = new IntPtr(); this.pRealPlayHandle[0] = CHCNetSDK.NET_DVR_RealPlay_V40(pLoginID1, ref lpClientInfo, null, pUser); pictureBox1.Refresh(); } #endregion }, string.Empty); }); Thread th = new Thread(tsVideo); th.IsBackground = true; th.Start(); } catch { MessageBox.Show("连接异常,建议重启"); Application.Exit(); } } private void VideoClose() { CHCNetSDK.NET_DVR_Cleanup(); } private void Form1_Load(object sender, EventArgs e) { InitConfig(); InitVideo(); } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { try { VideoClose(); } catch { Application.Exit(); } } #endregion #region 云台 private void button5_Click_1(object sender, EventArgs e) { YunControl(CHCNetSDK.TILT_UP);//上 } private void button8_Click_1(object sender, EventArgs e) { YunControl(CHCNetSDK.TILT_DOWN);//下 } private void button2_Click_1(object sender, EventArgs e) { YunControl(CHCNetSDK.PAN_LEFT); } private void button4_Click_1(object sender, EventArgs e) { YunControl(CHCNetSDK.PAN_RIGHT);//右 } private void button1_Click(object sender, EventArgs e) { YunControl(CHCNetSDK.ZOOM_OUT);//- } private void button3_Click_1(object sender, EventArgs e) { YunControl(CHCNetSDK.ZOOM_IN);// } private void button6_Click_1(object sender, EventArgs e) { YunControl(CHCNetSDK.UP_LEFT);//左上 } private void button7_Click_1(object sender, EventArgs e) { YunControl(CHCNetSDK.DOWN_LEFT);//左下 } private void button9_Click_1(object sender, EventArgs e) { YunControl(CHCNetSDK.UP_RIGHT);//右上 } private void button10_Click_1(object sender, EventArgs e) { YunControl(CHCNetSDK.DOWN_RIGHT);//右下 } private void YunControl(uint demo) { try { if (CHCNetSDK.NET_DVR_PTZControl_Other(pLoginID1, 1, demo, 0)) { Thread.Sleep(100); CHCNetSDK.NET_DVR_PTZControl_Other(pLoginID1, 1, CHCNetSDK.PAN_LEFT, 1); } } catch { } } #endregion #region 长按 private bool IsRun = false; private int Con = 0; private void button3_MouseDown_1(object sender, MouseEventArgs e) { Con = 1; timer1.Start(); IsRun = true; } private void button3_MouseUp_1(object sender, MouseEventArgs e) { Con = 0; timer1.Stop(); IsRun = false; ; } private void button1_MouseDown_1(object sender, MouseEventArgs e) { Con = -1; timer1.Start(); IsRun = true; } private void button1_MouseUp_1(object sender, MouseEventArgs e) { Con = 0; timer1.Stop(); IsRun = false; } private void timer1_Tick_1(object sender, EventArgs e) { if (IsRun) { if (Con == 1) YunControl_(CHCNetSDK.ZOOM_IN);// else if (Con == -1) YunControl_(CHCNetSDK.ZOOM_OUT);//- } } private void YunControl_(uint demo) { try { if (CHCNetSDK.NET_DVR_PTZControl_Other(pLoginID1, 1, demo, 0)) { Thread.Sleep(300); CHCNetSDK.NET_DVR_PTZControl_Other(pLoginID1, 1, demo, 1); } } catch { } } #endregion #region 加载配置 private string IP = string.Empty; private int Port = 0; private string Admin = string.Empty; private string Password = string.Empty; private void InitConfig() { try { IP = System.Configuration.ConfigurationManager.AppSettings["IP"].ToString(); Port = Convert.ToInt16(System.Configuration.ConfigurationManager.AppSettings["Port"].ToString()); Admin = System.Configuration.ConfigurationManager.AppSettings["Admin"].ToString(); Password = System.Configuration.ConfigurationManager.AppSettings["Passward"].ToString(); } catch { MessageBox.Show("配置出错"); Application.Exit(); } } #endregion private void pictureBox1_DoubleClick(object sender, EventArgs e) { int loginId = pLoginID1; BigScress frm = new BigScress(loginId, this.BindVideo1); frm.ShowDialog(this); } }}

【程序目录】
└─yundemo
    │  .gitattributes
    │  .gitignore
    │  yundemo.sln
    │  
    └─yundemo
        │  App.config
        │  BigScress.cs
        │  BigScress.Designer.cs
        │  BigScress.resx
        │  CHCNetSDK.cs
        │  Form1.cs
        │  Form1.Designer.cs
        │  Form1.resx
        │  Program.cs
        │  WMPlayer.ico
        │  yundemo.csproj
        │  
        ├─bin
        │  ├─Debug
        │  │  │  AudioRender.dll
        │  │  │  HCCore.dll
        │  │  │  HCNetSDK.dll
        │  │  │  PlayCtrl.dll
        │  │  │  SuperRender.dll
        │  │  │  yundemo.exe
        │  │  │  yundemo.exe.config
        │  │  │  yundemo.pdb
        │  │  │  
        │  │  └─HCNetSDKCom
        │  │          AnalyzeData.dll
        │  │          AudioIntercom.dll
        │  │          HCAlarm.dll
        │  │          HCAlarm.lib
        │  │          HCCoreDevCfg.dll
        │  │          HCDisplay.dll
        │  │          HCGeneralCfgMgr.dll
        │  │          HCGeneralCfgMgr.lib
        │  │          HCIndustry.dll
        │  │          HCPlayBack.dll
        │  │          HCPreview.dll
        │  │          HCPreview.lib
        │  │          HCVoiceTalk.dll
        │  │          libiconv2.dll
        │  │          msvcr90.dll
        │  │          OpenAL32.dll
        │  │          StreamTransClient.dll
        │  │          SystemTransform.dll
        │  │          
        │  └─Release
        ├─obj
        │  └─Debug
        │      │  DesignTimeResolveAssemblyReferences.cache
        │      │  DesignTimeResolveAssemblyReferencesInput.cache
        │      │  TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
        │      │  TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
        │      │  TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
        │      │  yundemo.BigScress.resources
        │      │  yundemo.csproj.CoreCompileInputs.cache
        │      │  yundemo.csproj.FileListAbsolute.txt
        │      │  yundemo.csproj.GenerateResource.cache
        │      │  yundemo.csprojAssemblyReference.cache
        │      │  yundemo.exe
        │      │  yundemo.Form1.resources
        │      │  yundemo.pdb
        │      │  yundemo.Properties.Resources.resources
        │      │  
        │      └─TempPE
        │              Properties.Resources.Designer.cs.dll
        │              
        └─Properties
                AssemblyInfo.cs
                Resources.Designer.cs
                Resources.resx
                Settings.Designer.cs
                Settings.settings
                

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复